<?php
/**
 * Created by PhpStorm.
 * @description:
 * @time:
 * @Author: yfl
 * @QQ 554665488
 * Date: 2018-5-26
 * Time: 11:34
 */
$db = new swoole\Mysql();
$config = [
    'host' => '127.0.0.1',
    'user' => 'root',
    'password' => 'Abc123!Abc',
    'database' => 'tp_shop'
];
$db->connect($config, function ($db, $result) {
    //执行sql的时候 需要传入一个回调函数，connect的结果不在返回值中，query 的结果也需要在回调函数中处理
    $db->query('show tables', function (Swoole\Mysql $mysql, $result) {
        var_dump($result);
        $mysql->close();
    });
});